package com.example.klinedemo.luPing

import android.content.Intent
import android.media.projection.MediaProjectionManager
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.example.klinedemo.R

class LuPingActivity : AppCompatActivity() {


    val mediaProjectionManager =
        getSystemService(MEDIA_PROJECTION_SERVICE) as MediaProjectionManager

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_lu_ping)
    }

    /**
     * 开始录屏
     */
    fun startLuPing() {
        val intent = mediaProjectionManager.createScreenCaptureIntent()
        startActivityForResult(intent, 100)
    }


    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
        if (requestCode != 100) return
        if (data == null) return
        // 通过mediaProjection 开始录屏
        val mediaProjection = mediaProjectionManager.getMediaProjection(resultCode, data)
       //  val h264EnCode = H264EnCode()

    }
}